package com.jt.config;

import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

/**
 * @outhor fufeixiang
 * @date 2021-04-23
 */
@Configurable  //标识我是一个配置类  相当于application.xml
@ComponentScan("com.jt")    //如果注解中只有value属性，则可以省略.
@PropertySource(value = "classpath:/user.properties",encoding = "UTF-8")
public class SpringConfig {

    @Value("${user.id}")
    private Integer id;
    @Value("${user.username}")
    private String username;
    @Bean
    public User User(){
        User user = new User();
        user.setUsername(username);
        user.setId(id);
        return user;
    }
}
